import {ApiRootUrl} from '../../../config/index.js'
import Dialog from '../../../@vant/weapp/dialog/dialog';
import {IMG_PATH} from '../../../config/index.js'
import Toast from '../../../@vant/weapp/toast/toast';
//获取应用实例
const app = getApp()
Page({
  data: {
    active:0,
    loadingFlag:false,
    userInfo: {},
    canIUse: wx.canIUse('button.open-type.getUserInfo'),
    //绑定宫格图片地址和文字
    dataList:[],
    topbg:"rgba(0,0,0,0)",
    width:wx.getSystemInfoSync().windowWidth,
    customFlag:false,
    value:'',
    infoList:[],
    imageurlList:[],
    statusBarHeight:''
  },
  onLoad: function () {
    
    this.setData({
      statusBarHeight:wx.getSystemInfoSync()['statusBarHeight']
    })
    let dataList = [{
      imgUrl:`/icon/zaishi.png`,
      textValue:'在职人员',
      navigateUrl:"../alllist/alllist?id=0",
      count:'0'
    },{
      imgUrl:`/icon/dairuzhi.png`,
      textValue:'在宿人员',
      navigateUrl:"../alllist/alllist?id=1",
      count:'0'
    },{
      imgUrl:`/icon/lisu.png`,
      textValue:'离宿人员',
      navigateUrl:"../alllist/alllist?id=2",
      count:'0'
    },{
      imgUrl:`/icon/lizhi.png`,
      textValue:'离职人员',
      navigateUrl:"../alllist/alllist?id=3",
      count:'0'
    },
    // {
    //   imgUrl:`${IMG_PATH}/company/违纪人员.png`,
    //   textValue:'违纪人员',
    //   navigateUrl:"",
    //   count:'0'
    // },{
    //   imgUrl:`${IMG_PATH}/company/待分配.png`,
    //   textValue:'待分配',
    //   navigateUrl:"",
    //   count:'0'
    // }
  ];
    let imageurlList = [{
      id:'1',
      url:`${IMG_PATH}/center/laowu_renyuan.png`
    },{
      id:'2',
      url:`${IMG_PATH}/center/laowu_renyuan.png`
    },{
      id:'3',
      url:`${IMG_PATH}/center/laowu_renyuan.png`
    }];
    let imageurlList1 = [{
      id: '1',
      url: `${IMG_PATH}/center/laowu_banner1.png`
    }, {
      id: '2',
      url: `${IMG_PATH}/center/laowu_banner2.png`
    }]
    this.setData({
      dataList:dataList,
      imageurlList:imageurlList,
      imageurlList1:imageurlList1
    })
  },
  backClick(event){
    console.log(event);
    wx.navigateBack();
    // Dialog.confirm({
    //   title: '返回',
    //   message: '请确认是否返回？',
    // }).then(() => {
    //   wx.navigateBack();
    // }).catch(() => {
    //   console.log('取消')
    // });
  },
  onChange(event) {
    console.log(event.detail)
    if(event.detail == 2){
      console.log("点击新建")
    }else{
      this.setData({ active: event.detail });
    }
    
  },
  newAddTap(event){
    console.log("点击新建")
  },
  //点击信息触发事件
  msgTap(){
    wx.navigateTo({
      url: '../message/messagePush/messagePush',
    })
  },
  //点击搜索框触发事件
  onSearch(event){
    Toast(`${event.detail}`);
    console.log(event)
  },
  //点击图片触发事件
  imageTab(event){
    console.log(event.target.dataset.id);
  },
  //监听用户下拉刷新事件
  onPullDownRefresh(){
    wx.showNavigationBarLoading();
    setTimeout(function(){
      wx.hideNavigationBarLoading(); //完成停止加载图标
      wx.stopPullDownRefresh();
    },5000)
  },
  /**
   * 页面滑动监听
  */
  onPageScroll:function(e){
    console.log(e.scrollTop)
    if(e.scrollTop >10){
      this.setData({
        topbg:"#ACDAC3"
      })
    }else{
      this.setData({
        topbg:"rgba(0,0,0,0)"
      })
    }
  },
})
